<template>
  <div>
    这是index组件
    <h1>这是parent---{{ $store.state.count }}</h1>
    <el-button @click="addCount">自增</el-button>

    <!-- store传参 -->
    <el-button @click="setList">setList</el-button>

    <!-- 父组件像子组件传参第二步 -->
    <!-- 
    <child-1 :child1Value.sync="count"></child-1>
    <child-2 :child2Value.sync="count"></child-2> 
    -->
    <child-1></child-1>
    <child-2></child-2>

    <!-- 验证store是否能够使用 -->
    {{ $store.state.count }}
  </div>
</template>

<script>
// 在当前页面显示child1和child2
import Child1 from "./child1.vue";
import Child2 from "./child2.vue";

export default {
  components: {
    Child1,
    Child2,
  },
  data() {
    return {
      //   count: 0,
    };
  },
  methods: {
    addCount() {
      //   this.count++;
      //   操作公共仓库的count的数据
      this.$store.commit("addCount");
    },
    setList(){
        this.$store.commit('setList','这是从parent中接收的值')
    }

    
  },
};
</script>

<style scoped lang="scss">
</style>